{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" onclick="category_add()">添加分类</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>分类ID</th>
                    <th>分类名称</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo['id']}</td>
                        <td>{$vo['title']}</td>
                        <td>{$vo['sort']}</td>
                        <td>
                            <a style="text-decoration:none"  onclick="category_edit({$vo.id})"  class="layui-btn layui-btn-normal layui-btn-xs">
                                <i class="layui-icon layui-icon-edit"></i>编辑
                            </a>
                            <a style="text-decoration:none" onClick="del({$vo.id},'删除')" class="layui-btn layui-btn-danger layui-btn-xs">
                                <i class="layui-icon layui-icon-delete"></i>删除
                            </a>
                        </td>
                    </tr>
                {/volist}

                {if condition="empty($list)"}
                    <tr><td colspan='11' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
               
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;

        
    })

    //添加分类
    function category_add() {
        var url  = "{:url('/admin/card_category_add')}";
        layer.open({
            type: 2,
            title: '添加分类',
            shadeClose: false,
            shade: 0.3,
            area: ['40%', '40%'],
            content: url,
        });
    }

    //编辑分类
    function category_edit(id) {
        var url  = "{:url('/admin/card_category_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑分类',
            shadeClose: false,
            shade: 0.3,
            area: ['40%', '40%'],
            content: url,
        });
    }

    //删除
    function del(id,type_name){
        layer.confirm('确认要执行'+type_name+'操作吗？',function(){
            var url = "{:url('/admin/card_category_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id},function(data){
                if(data.status == 1){
                    layer.msg('操作成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }
</script>
</body>
</html>


